package com.seuic.hnjiningposapp.hnapps.ui.view.dialog;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ToastUtils;
import com.lxj.xpopup.core.BasePopupView;
import com.seuic.hnjiningposapp.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * 输入操作员密码
 */
public class OperatorBInputManagerPw extends BasePopupView {
    Unbinder bind;
    @BindView(R.id.input_old_edtext)
    EditText inputOldEdtext;
    @BindView(R.id.input_newpassword_edtext)
    EditText inputNewpasswordEdtext;
    @BindView(R.id.input_password_gztext)
    Button inputPasswordGztext;
    @BindView(R.id.input_password_outtext)
    Button inputPasswordOuttext;
    OperatorBInputManagerCallBack mOperatorBInputManagerCallBack;

    public OperatorBInputManagerPw(@NonNull Context context, OperatorBInputManagerCallBack operatorBInputManagerCallBack) {
        super(context);
        mOperatorBInputManagerCallBack = operatorBInputManagerCallBack;
    }

    @Override
    protected int getPopupLayoutId() {
        return R.layout.operatorbinputmanagerpw;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        bind = ButterKnife.bind(this);
    }

    @OnClick({R.id.input_password_gztext, R.id.input_password_outtext})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.input_password_gztext:
                if (inputOldEdtext.getText().toString().equals("")) {
                    ToastUtils.showLong("请输入操作员账号");
                    return;
                }
                if (inputNewpasswordEdtext.getText().toString().equals("")) {
                    ToastUtils.showLong("请输入操作员密码");
                    return;
                }
                mOperatorBInputManagerCallBack.OperatorBInputManagerok(inputOldEdtext.getText().toString(), inputNewpasswordEdtext.getText().toString());
                break;
            case R.id.input_password_outtext:

                mOperatorBInputManagerCallBack.OperatorBInputManagerout();
                break;
        }
    }

    public interface OperatorBInputManagerCallBack {
        void OperatorBInputManagerok(String acc, String pw);

        void OperatorBInputManagerout();
    }

    @Override
    protected void onDismiss() {
        super.onDismiss();
        //注解解绑
        if (bind != null && bind != Unbinder.EMPTY) {
            bind.unbind();
        }
        this.bind = null;
    }

}
